<!-- 顶部返回 -->
<template>
  <div class="header-top">
    <span class="go-back" @click="backClick()"> {{ btnText }} </span>
    <h3>{{ title }}</h3>
  </div>
</template>

<script type="text/javascript">
export default {
  name: "BackBtnText",
  props: {
    title: {
      type: String,
      default: "text",
    },
    routeName: {
      type: String,
      default: "",
    },
    btnText: {
      type: String,
      default: "返回",
    },
  },
  data() {
    return {};
  },
  methods: {
    backClick() {
      if (this.$props.routeName) {
        this.$router.push({
          name: this.$props.routeName,
        });
      } else {
        this.$router.go(-1);
      }
    },
  },
};
</script>

<style lang="less" scoped>
.go-back {
  display: block;
  width: 60px;
  height: 32px;
  color: #0052d9;
  text-align: center;
  line-height: 32px;
  background: rgba(45, 143, 255, 0.1);
  margin-right: 20px;
  cursor: pointer;
  border-radius: 2px;
}
.header-top {
  display: flex;
  align-items: center;
  background: #fff;
  padding: 20px;
  border-radius: 6px;
}
</style>
